<?php

namespace App\Services;

use App\Repositories\Contracts\ActivityRepository;

class ActivityService
{
    private $activityRepository;

    public function __construct(ActivityRepository $activityRepository)
    {
        $this->activityRepository = $activityRepository;
    }

    /**
     * 获取列表
     *
     * @param array|null $param
     */
    public function getList($param = null)
    {
        try {
            $filter = [
                'status' => 1,
            ];
            $result = $this->activityRepository->paginate($param['per_page'] ?? null, $filter);
            return $result;
        } catch (\Throwable $th) {
            throw $th;
        }
    }

    /**
     * 获取详情
     *
     * @param int $id
     * @return object|array
     */
    public function getInfo($id)
    {
        try {
            $result = $this->activityRepository->find($id);
            return $result;
        } catch (\Throwable $th) {
            throw $th;
        }
    }
}
